package com.example.test1.serviceimpl;

import com.example.test1.bean.UserBean;
import com.example.test1.bean.UserImgBean;
import com.example.test1.mapper.UserMapper;
import com.example.test1.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;
    @Override
    public PageInfo<UserBean>  selectUser4Page(Integer page,Integer pageSize){
        PageHelper.startPage(page,pageSize);
        List<UserBean> users = userMapper.selectUser4Page();
        return new PageInfo<UserBean>(users);
    }
    @Override
    public int updateUser(UserBean userBean){
        return userMapper.updateUser(userBean);
    }
    @Override
    public UserBean getUserById(int id){
        return userMapper.getUserById(id);
    }
    @Override
    public int deleteUser(int id){
        return userMapper.deleteUser(id);
    }
    @Override
    public int insertUser(UserBean userBean){
        return userMapper.insertUser(userBean);
    }
    @Override
    public List<UserBean> getAllUser(){
        return userMapper.getAllUser();
    }
    @Override
    public UserBean loginIn(String name, String password){
        return userMapper.getInfo(name, password);
    }
    @Override
    public int insertUserImg(UserImgBean userImgBean){
        return userMapper.insertUserImg(userImgBean);
    }
    @Override
    public List<UserImgBean> getUserImgsById(int user_id){
        return userMapper.getUserImgsById(user_id);
    }
    @Override
    public int delUserImg(String id){
        return userMapper.delUserImg(id);
    }
}
